package date_;

import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;

/**
 * 一件商品生产日期是2017/7/12,保质期5年，算出失效日期
 */
public class DateTest03 {
    public static void main(String[] args) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR ,2017);
        cal.set(Calendar.MONTH,7);
        cal.set(Calendar.DAY_OF_MONTH,12);
        Date time = cal.getTime();
        System.out.println(time);
        System.out.println("商品的生产日期为"+cal.get(Calendar.YEAR)+"年"+cal.get(Calendar.MONTH)+"月"+cal.get(Calendar.DAY_OF_MONTH)+"日");
cal.add(Calendar.YEAR,5);
        System.out.println("商品的失效日期为"+cal.get(Calendar.YEAR)+"年"+cal.get(Calendar.MONTH)+"月"+cal.get(Calendar.DAY_OF_MONTH)+"日");


    }
}
